<?php
class D_DB
{	
	private static  $instance = null;
	public static function factory($zend_config)
	{
		$dbhost = $zend_config->database->params->host;
		$username =	$zend_config->database->params->username;
		$password =	$zend_config->database->params->password;
		$dbname = $zend_config->database->params->dbname;
		$charset = $zend_config->database->params->charset;	
	
		$pconnect =$zend_config->database->params->pconnect;
		$adapter = $zend_config->database->adapter;	
		if(!$charset)
			$charset ='utf8';
		else
			$charset = $zend_config->database->params->charset;
		if(!$pconnect)
			$pconnect =false;
		if(!$adapter)
			$adapter = 'Mysql';
		else
			$adapter = $zend_config->database->adapter;	
		if($adapter =='Mysql')
		{
			
			if(self::$instance == null)
				return self::$instance = new D_Adapter_Mysql($dbhost, $username, $password, $dbname, $charset, $pconnect);
			else 
				return self::$instance;
		}
		elseif($adapter == 'Pdo')
		{	
			if(self::$instance == null)
				return self::$instance = new D_Adapter_Pdo($dbhost, $username, $password, $dbname,$charset, $pconnect);
			else 
				return self::$instance;
		}
		
		return $db;
	}
}
?>